package com.zb.service.impl;
import com.zb.mapper.ExchangescoreMapper;
import com.zb.entity.Exchangescore;
import org.springframework.stereotype.Service;
import com.zb.service.ExchangescoreService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.zb.util.PageUtil;
import java.util.ArrayList;
import java.util.HashMap;

@Service
public class ExchangescoreServiceImpl implements ExchangescoreService {

    @Autowired
    private ExchangescoreMapper exchangescoreMapper;

    public Exchangescore getExchangescoreById(Long id)throws Exception{
        return exchangescoreMapper.getExchangescoreById(id);
    }

    public List<Exchangescore>	getExchangescoreListByMap(Map<String,Object> param)throws Exception{
        return exchangescoreMapper.getExchangescoreListByMap(param);
    }

    public Integer getExchangescoreCountByMap(Map<String,Object> param)throws Exception{
        return exchangescoreMapper.getExchangescoreCountByMap(param);
    }

    public Integer qdtxAddExchangescore(Exchangescore exchangescore)throws Exception{
            //exchangescore.setCreatedTime(new Date());
            return exchangescoreMapper.insertExchangescore(exchangescore);
    }

    public Integer qdtxModifyExchangescore(Exchangescore exchangescore)throws Exception{
        //exchangescore.setUpdatedTime(new Date());
        return exchangescoreMapper.updateExchangescore(exchangescore);
    }

    public Integer qdtxDeleteExchangescoreById(Long id)throws Exception{
        return exchangescoreMapper.deleteExchangescoreById(id);
    }

    public PageUtil<Exchangescore> queryExchangescorePageByMap(Map<String,Object> param,Integer index,Integer size)throws Exception{
        param.put("start",(index-1)*size);
        param.put("size", size);

        List<Exchangescore> exchangescoreList = exchangescoreMapper.getExchangescoreListByMap(param);
        Integer count = exchangescoreMapper.getExchangescoreCountByMap(param);

        PageUtil<Exchangescore> page = new PageUtil<Exchangescore>();
        page.setData(exchangescoreList);
        page.setIndex(index);
        page.setSize(size);
        page.setCount(count);
        return page;
    }

    public Integer qdtxBatchDeleteExchangescore(String ids)throws Exception{
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return exchangescoreMapper.batchDeleteExchangescore(param);
    }


}
